package org.carabiner.mockutil;

import org.jmock.core.Invocation;
import org.jmock.core.InvocationMatcher;

/**
 * This class matches invocations to a certain dynamic stub.  
 * The only interesting method here is {@link #matches(Invocation)}.
 * 
 * @author <a href="mailto:bignate@gmail.com">Nathan Eror</a>
 */
public class DynamicStubInvocationMatcher implements InvocationMatcher
{
  private DynamicStub stub;

  public DynamicStubInvocationMatcher(DynamicStub dynamicStub)
  {
    stub = dynamicStub;
  }

  public void verify()
  {
    // There is no need to verify
  }

  public StringBuffer describeTo(StringBuffer buffer)
  {
    return stub.describeTo(buffer);
  }

  public boolean matches(Invocation invocation)
  {
    return stub.canInvoke(invocation);
  }

  public void invoked(Invocation invocation)
  {
    // We don't care if it's been invoked because we're never verifying.
  }

  public boolean hasDescription()
  {
    return false;
  }
}
